# config.py
import torch

class Config:
    # 数据路径
    data_dir = './data'
    train_src_file = 'TM-training-set/chinese.txt'  # 源语言文件
    train_tgt_file = 'TM-training-set/english.txt'  # 目标语言文件
    dev_file = 'Dev-set/Niu.dev.txt'            # 验证集源语言文件
    reference_file = 'Reference-for-evaluation/Niu.test.reference'  # 参考文件
    # reference_file = 'Dev-set/Niu.dev.txt' #验证集翻译
    save_model_path = './best_model.pth'  # 模型保存路径
    translations_file = reference_file.split('/')[0] + '_translations.txt'

    # 模型参数
    embedding_dim = 128     # 嵌入层维度 
    hidden_dim = 128          # 隐藏层维度
    num_heads = 8            # 多头注意力头数 
    num_layers = 3          # Transformer 层数 
    dropout = 0.1           # Dropout率 
    max_seq_length = 40     # 最大序列长度 
    # 训练参数
    device = "cuda:0" if torch.cuda.is_available() else "cpu"  # 默认设备
    batch_size = 32         # 批次大小 
    learning_rate = 3e-4  # 学习率
    epochs = 100              # 训练轮数
    clip_grad_norm = 1.0     # 梯度裁剪阈值 
    patience = epochs // 10 if epochs // 10 > 10 else 5 # 早停耐心 
    
    # 新增训练策略参数 
    warmup_steps = 2000      # 学习率预热步数 
    noam_factor = 1.0        # Factor for NoamOpt 
    label_smoothing = 0.0    # 标签平滑系数
    weight_decay = 0.0       # 权重衰减 
    
    # 多GPU支持
    multi_gpu = torch.cuda.device_count() > 1  # 是否启用多 GPU 训练
    
    # BLEU-4评估阈值
    bleu4_threshold = 0.25   # 设置一个合理的阈值